package com.example.service.impl;

import java.util.Optional;

import org.springframework.stereotype.Component;

import com.alipay.sofa.runtime.api.annotation.SofaService;
import com.alipay.sofa.runtime.api.annotation.SofaServiceBinding;
import com.example.service.UserService;
import com.example.vo.UserVO;

//为了区分 XML 方式发布的 JVM 服务，注解上需要增加 uniqueId 属性。
@Component
//@SofaService(uniqueId = "userService")

//这里默认使用的本地文件作为注册中心
@SofaService(interfaceType = UserService.class, bindings = { @SofaServiceBinding(bindingType = "bolt") })
public class UserServiceImpl implements UserService {
	@Override
	public UserVO profile(String name) {
		
		name = Optional.ofNullable(name).orElse("world");
		
		UserVO user = new UserVO();
		user.setAge(20);
		user.setName(name);
		user.setEmail("xx@qq.com");
		return user;
	}
}